<template>
    <div class="order">
        <div class="order-card-body" :key="index" v-if="orderInfo">
          <div class="order-card-wrap">
            <img :src="orderInfo.shopInfo.image_path" alt>
            <div class="order-card-content">
              <div class="order-card-head">
                <div class="title">
                  <a>
                    <span h5lineHeight>{{orderInfo.shopInfo.name}}</span>
                    <i class="fa fa-angle-right"></i>
                  </a>
                  <p>订单已完成</p>
                </div>
              </div>
              <div class="order-card-detail" v-for="(item,index) in orderInfo.selectFood">
                <p class="detail h5lineHeight">{{item.name}}</p>
                <p class="price">¥{{item.activity.fixed_price}}</p>
              </div>
            </div>
          </div>
          <div class="order-card-bottom">
              <span>总计￥{{totalPrice}}(包含配送费3)</span>
            <button class="cardbutton" @click="$router.push('/shop')">再来一单</button>
          </div>
        </div>
        <div class="noOrder" v-else>
            <i class="fa fa-frown-o"></i>
            <div>您还没下单呢</div>
            
        </div>
         <!-- 45px遮盖tabbar -->
         <div style="height: 45px;"></div>
         <tabBar :data='tabBarData'/>
      </div>
  </template>

<script>
    import tabBar from '../components/tabBar.vue'
    export default {
        name: 'order',
        orderInfo: {},
        totalPrice: Number,
        data() {
            return {
                tabBarData: [{
                    title: "首页",
                    icon: 'home',
                    path: '/home'
                }, {
                    title: "订单",
                    icon: 'file-text-o',
                    path: '/order'
                }, {
                    title: "我的",
                    icon: 'user',
                    path: '/me'
                }]
            }
        },
        created() {
            this.getData();
            console.log(this.totalPrice);
            console.log(this.orderInfo)
        },
        methods: {
            getData() {
                this.orderInfo = this.$store.getters.orderInfo;
                this.totalPrice = this.$store.getters.totalPrice;
            }
        },
        components: {
            tabBar
        }
    }
</script>

<style scoped>
    .h5lineHeight {
        display: flex;
        align-items: center;
        justify-content: left;
        line-height: normal;
    }
    
    .order {
        width: 100%;
        height: 100%;
        overflow: auto;
        box-sizing: border-box;
        margin-bottom: 2.666667vw;
    }
    
    .order-card-body {
        margin-top: 2.666667vw;
        background-color: #fff;
        padding: 3.733333vw 0 0 4vw;
    }
    
    .order-card-wrap {
        display: flex;
    }
    
    .order-card-wrap>img {
        height: 8.533333vw;
        border-radius: 0.533333vw;
        border: 1px solid #eee;
        width: 8.533333vw;
        margin-right: 2.666667vw;
    }
    
    .order-card-content {
        flex: 1;
    }
    
    .order-card-head {
        border-bottom: 1px solid #eee;
        padding-right: 3.466667vw;
        padding-bottom: 2.666667vw;
    }
    
    .order-card-head .title {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .order-card-head .title>a {
        font-size: 1rem;
        line-height: 1.5em;
        color: #333;
        text-decoration: none;
    }
    
    .order-card-head .title>a>span {
        display: inline-block;
        max-width: 10em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .order-card-head .title>a>i {
        margin-left: 1.333333vw;
        color: #ccc;
        vertical-align: super;
    }
    
    .order-card-head .title>p {
        font-size: 0.8rem;
        text-align: right;
        color: #333;
        max-width: 14em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .date-time {
        font-size: 0.6rem;
        color: #999;
    }
    
    .order-card-detail {
        display: flex;
        justify-content: space-between;
        padding: 4vw 3.466667vw 4vw 0;
        font-size: 0.8rem;
    }
    
    .order-card-detail .detail {
        color: #666;
        display: flex;
        align-items: center;
    }
    
    .order-card-detail .price {
        flex-basis: 16vw;
        text-align: right;
        color: #333;
        font-weight: 700;
    }
    
    .order-card-bottom {
        display: flex;
        border-top: 1px solid #eee;
        padding: 2.666667vw 4.266667vw;
        justify-content: flex-end;
    }
    
    .order-card-bottom span {
        margin-right: 8vh;
        line-height: 2;
        font-size: larger;
    }
    
    .cardbutton {
        padding: 1.333333vw 2.666667vw;
        border: 1px solid #2395ff;
        border-radius: 0.533333vw;
        background-color: transparent;
        outline: none;
        font-size: 0.8rem;
        color: #2395ff;
        margin-left: 2vw;
    }
    
    .noOrder {
        margin: 25vh 25vh;
        position: relative;
    }
    
    .noOrder i {
        font-size: 15vh;
    }
    
    .noOrder i {
        position: absolute;
        left: 50%;
        top: -40%;
        transform: translate(-50%, -50%);
    }
    
    .noOrder div {
        width: 400px;
    }
    
    .noOrder div {
        position: absolute;
        left: 50%;
        top: 40%;
        transform: translate(-11%, 400%);
    }
</style>
</style>